package cn.buildoncloud.labor.workermanapplet.common.base;

import cn.buildoncloud.labor.workermanapplet.common.Constant;
import lombok.Data;

import java.io.Serializable;

/**
 * Created by wizzer on 2016/12/21.
 */
@Data
public class Result implements Serializable {
    private static final long serialVersionUID = 1L;

    private int code;
    private String msg;
    private Object data;

    public Result() {}

    public Result(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result NEW() {
        return new Result();
    }

    public static Result success(String content) {
        return new Result(0, content, null);
    }

    public static Result success(String content, Object data) {
        return new Result(0, content, data);
    }

    public static Result error(int code, String content) {
        return new Result(code, content, null);
    }

    public static Result error(String content) {
        return new Result(1, content, null);
    }

    public static Result success() {
        return new Result(0, Constant.API_OPERATION_SUCCESS, null);
    }

    public static Result error() {
        return new Result(1, Constant.API_OPERATION_FAILED, null);
    }

}
